package org.example.blog.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class TextUtils {
    public static final String regEx = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";

    public static boolean isEmpty(String text){
        return text == null || text.length() == 0;
    }


    public static boolean isEmailAddressOk(String mailAddress){

//        先获取正则规则
        Pattern p = Pattern.compile(regEx);
//        在进行正则比对
        Matcher m = p.matcher(mailAddress);
//        返回结果
        return m.matches();
    }
}
